home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1987 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: news.cencom.net!ns!tanp
  2. From: tanp@ns (Bill Wendling)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: ATTENTION C EXPERTS!! Extern Declarations - NEED HELP!
  5. Date: 18 Jan 1996 06:25:06 GMT
  6. Organization: Cen-Com Internet
  7. Message-ID: <4dkp42$k1q@news.cencom.net>
  8. References: <DCD9516F@brazerko.com>
  9. NNTP-Posting-Host: ns.cencom.net
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. tcassel inexplicably wrote:
  13. } I am having difficulty understanding the following code and every book I
  14. } get on
  15. } the subject does not explain the multiple MACROS that are in the
  16. } definition.
  17.  
  18. } extern unsigned int _NEAR _CDECL _osversion;
  19.  
  20. } /* where _NEAR and _CDECL are macros defined as:*/
  21.  
  22. } #ifndef NO_KEYS
  23. }     #define _CDECL cdecl
  24. }     #define _NEAR near
  25. } #else
  26. }     #define _CDECL
  27. }     #define _NEAR
  28. } #endif 
  29.  
  30. } /* There is only two places where cdecl and near are mentioned in the rest
  31. } of
  32. } the program - the following appears once in two seperate header files */
  33.  
  34. } #define _NEAR near
  35. } #define _CDECL cdecl
  36.  
  37. } /* I am attempting to make this program ansi C compilable, and am stuck on
  38. } this
  39. } as I dont understand what the above code is doing. Any help would be
  40. } greatly
  41. } appreciated. Kind Regards, Thea Cassel  tcassel@sisyphus.cit.gu.edu.au
  42. } */
  43.  
  44. NEAR tells a 16 bit operating system that the pointer is to the current
  45. segment of memory.  As opposed to a FAR pointer which can access another
  46. segment of memory.  CDECL seems to be telling the program that the parameters
  47. are pushed in C style when being passed as opposed to Pascal which pushes
  48. them on the stack in a different way.  (I could be wrong in CDECL, though.)
  49.  
  50. Anyway, neither of these are in the K&R for good reason.  C was meant to 
  51. run on UNIX which is a real operating system, instead of DOS, which isn't.
  52. I've only seen these Macros used for DOS and Windoze programs.
  53.  
  54. --
  55. Bill Wendling         | "Pinky, are you thinking what I'm thinking?"
  56. tanp@ns.cencom.net  | "I think so, Brain, but burlap chafes me so."
  57. "Boom Shanka"       | Finger me for my Geek Code...NOW!
  58.